package sample.provider.ddl;


public class SQLiteIndex extends SQLiteObject {
    private String mTargetTable;
    private String mTargetColumn;

    public SQLiteIndex(String targetTable) {
        super(targetTable + "_index");
        mTargetTable = targetTable;
    }

    public void setTargetColumn(String targetColumn) {
        mTargetColumn = targetColumn;
    }

    @Override
    String toDropSql() {
        return "DROP INDEX IF EXISTS " + getName();
    }

    @Override
    String toCreateSql() {
        StringBuilder sql = new StringBuilder();
        sql.append("CREATE INDEX IF NOT EXISTS ").append(getName());
        sql.append("\n ON ").append(mTargetTable).append('(').append(mTargetColumn).append(')');
        return sql.toString();
    }
}
